/**
 * 一些静态配置
 */

/**
 * 热词
 */
 export const hotKey = {
	keyWords: [],
	methods: [],
}

/**
 * 数据类型
 */
export const dataType = [{
	name: 'bigint'
}, {
	name: 'binary'
}, {
	name: 'bit',
}, {
	name: 'bit',

}, {
	name: 'blob',

}, {
	name: 'char',

}, {
	name: 'date',

}, {
	name: 'datetime',

}, {
	name: 'decimal',
	size: 65,
	decimalDigits: 30
}, {
	name: 'double',
	defultSize: 10,
	defaultDecimalDigits: 2,
	size: 30,
	decimalDigits: 30
}, {
	name: 'enum',

}, {
	name: 'float',
	size: 255,
	decimalDigits: 30
}, {
	name: 'geometry'
}, {
	name: 'geometrycollection',

}, {
	name: 'int',

}, {
	name: 'integer',

}, {
	name: 'json',

}, {
	name: 'linestring',

}, {
	name: 'longblob',

}, {
	name: 'longtext',

}, {
	name: 'mediumblob',

}, {
	name: 'mediumint',

}, {
	name: 'mediumtext',

}, {
	name: 'multilinestring',

}, {
	name: 'multipoint',

}, {
	name: 'multipolygon',

}, {
	name: 'numeric',

}, {
	name: 'point',

}, {
	name: 'polygon',

}, {
	name: 'real',

}, {
	name: 'set',

}, {
	name: 'smallint',

}, {
	name: 'text',

}, {
	name: 'time',

}, {
	name: 'timestamp',

}, {
	name: 'tinyblob',

}, {
	name: 'tinyint',

}, {
	name: 'tinytext',

}, {
	name: 'varbinary',

}, {
	name: 'varchar',
	default: 255,

}]
/**
 * 字符集
 */
export const characterSets = [{
	name: 'armscii8',
	children: [{
		name: 'armscii8_bin'
	}, {
		name: 'armscii8_general_ci'
	}
	],
},
{
	name: 'ascii',
	children: [{
		name: 'ascii_bin'
	}, {
		name: 'ascii_general_ci'
	}
	],
}, {
	name: 'big5',
	children: [{
		name: 'big5_bin'
	}, {
		name: 'big5_general_ci'
	}],
}, {
	name: 'binary',
	children: [{
		name: 'binary'
	}],
}, {
	name: 'cp850',
	children: [{
		name: 'cp850_bin'
	}, {
		name: 'cp850_general_ci'
	}],
}, {
	name: 'cp852',
	children: [{
		name: 'cp852_bin'
	}, {
		name: 'cp852_general_ci'
	}],
}, {
	name: 'cp866',
	children: [{
		name: 'cp866_bin'
	}, {
		name: 'cp866_general_ci'
	}],
}, {
	name: 'cp932',
	children: [{
		name: 'cp932_bin'
	}, {
		name: 'cp932_japanese_ci'
	}],
}, {
	name: 'cp1250',
	children: [{
		name: 'cp1250_bin'
	}, {
		name: 'cp1250_croatian_ci'
	}, {
		name: 'cp1250_czech_cs'
	}, {
		name: 'cp1250_general_ci'
	}, {
		name: 'cp1250_polish_ci'
	}],
}, {
	name: 'cp1251',
	children: [{
		name: 'cp1251_bin'
	}, {
		name: 'cp1251_bulgarian_ci'
	}, {
		name: 'cp1251_general_ci'
	}, {
		name: 'cp1251_general_cs'
	}, {
		name: 'cp1251_ukrainian_ci'
	}],
}, {
	name: 'cp1256',
	children: [{
		name: 'cp1256_bin'
	}, {
		name: 'cp1256_general_ci'
	}],
}, {
	name: 'cp1257',
	children: [{
		name: 'cp1257_bin'
	}, {
		name: 'cp1257_general_ci'
	}, {
		name: 'cp1257_lithuanian_ci'
	}],
}, {
	name: 'dec8',
	children: [{
		name: 'dec8_bin'
	}, {
		name: 'cp1257_gdec8_swedish_cieneral_ci'
	}],
}, {
	name: 'eucjpms',
	children: [{
		name: 'eucjpms_bin'
	}, {
		name: 'eucjpms_japanese_ci'
	}],
}, {
	name: 'euckr',
	children: [{
		name: 'euckr_bin'
	}, {
		name: 'euckr_korean_ci'
	}],
}, {
	name: 'gb2312',
	children: [{
		name: 'gb2312_bin'
	}, {
		name: 'gb2312_chinese_ci'
	}],
}, {
	name: 'gb18030',
	children: [{
		name: 'gb18030_bin'
	}, {
		name: 'gb18030_chinese_ci'
	}, {
		name: 'gb18030_unicode_520_ci'
	}],
}, {
	name: 'gbk',
	children: [{
		name: 'gbk_bin'
	}, {
		name: 'gbk_chinese_ci'
	}],
}, {
	name: 'geostd8',
	children: [{
		name: 'geostd8_bin'
	}, {
		name: 'geostd8_general_ci'
	}],
}, {
	name: 'greek',
	children: [{
		name: 'greek_bin'
	}, {
		name: 'greek_general_ci'
	}],
}, {
	name: 'hebrew',
	children: [{
		name: 'hebrew_bin'
	}, {
		name: 'hebrew_general_ci'
	}],
}, {
	name: 'hp8',
	children: [{
		name: 'hp8_bin'
	}, {
		name: 'hp8_english_ci'
	}],
}, {
	name: 'keybcs2',
	children: [{
		name: 'keybcs2_bin'
	}, {
		name: 'keybcs2_general_ci'
	}],
}, {
	name: 'koi8r',
	children: [{
		name: 'koi8r_bin'
	}, {
		name: 'koi8r_general_ci'
	}],
}, {
	name: 'koi8u',
	children: [{
		name: 'koi8u_bin'
	}, {
		name: 'koi8u_general_ci'
	}],
}, {
	name: 'latin1',
	children: [{
		name: 'latin1_bin'
	}, {
		name: 'latin1_danish_ci'
	}, {
		name: 'latin1_general_ci'
	}, {
		name: 'latin1_general_cs'
	}, {
		name: 'latin1_german1_ci'
	}, {
		name: 'latin1_german2_ci'
	}, {
		name: 'latin1_spanish_ci'
	}, {
		name: 'latin1_swedish_ci'
	}],
}, {
	name: 'latin2',
	children: [{
		name: 'latin2_bin'
	}, {
		name: 'latin2_croatian_ci'
	}, {
		name: 'latin2_czech_cs'
	}, {
		name: 'latin2_general_ci'
	}, {
		name: 'latin2_hungarian_ci'
	}],
}, {
	name: 'latin5',
	children: [{
		name: 'latin5_bin'
	}, {
		name: 'latin5_turkish_ci'
	}],
}, {
	name: 'latin7',
	children: [{
		name: 'latin7_bin'
	}, {
		name: 'latin7_estonian_cs'
	}, {
		name: 'latin7_general_ci'
	}, {
		name: 'latin7_general_cs'
	}],
}, {
	name: 'macce',
	children: [{
		name: 'macce_bin'
	}, {
		name: 'macce_general_ci'
	}],
}, {
	name: 'macroman',
	children: [{
		name: 'macroman_bin'
	}, {
		name: 'macroman_general_ci'
	}],
}, {
	name: 'sjis',
	children: [{
		name: 'sjis_bin'
	}, {
		name: 'sjis_japanese_ci'
	}],
}, {
	name: 'swe7',
	children: [{
		name: 'swe7_bin'
	}, {
		name: 'swe7_swedish_ci'
	}],
}, {
	name: 'tis620',
	children: [{
		name: 'tis620_bin'
	}, {
		name: 'tis620_thai_ci'
	}],
}, {
	name: 'ucs2',
	children: [{
		name: 'ucs2_bin'
	}, {
		name: 'ucs2_croatian_ci'
	}, {
		name: 'ucs2_czech_ci'
	}, {
		name: 'ucs2_danish_ci'
	}, {
		name: 'ucs2_esperanto_ci'
	}, {
		name: 'ucs2_estonian_ci'
	}, {
		name: 'ucs2_general_ci'
	}, {
		name: 'ucs2_general_mysql500_ci'
	}, {
		name: 'ucs2_german2_ci'
	}, {
		name: 'ucs2_hungarian_ci'
	}, {
		name: 'ucs2_icelandic_ci'
	}, {
		name: 'ucs2_latvian_ci'
	}, {
		name: 'ucs2_lithuanian_ci'
	}, {
		name: 'ucs2_persian_ci'
	}, {
		name: 'ucs2_polish_ci'
	}, {
		name: 'ucs2_roman_ci'
	}, {
		name: 'ucs2_romanian_ci'
	}, {
		name: 'ucs2_sinhala_ci'
	}, {
		name: 'ucs2_slovak_ci'
	}, {
		name: 'ucs2_slovenian_ci'
	}, {
		name: 'ucs2_spanish_ci'
	}, {
		name: 'ucs2_spanish2_ci'
	}, {
		name: 'ucs2_swedish_ci'
	}, {
		name: 'ucs2_turkish_ci'
	}, {
		name: 'ucs2_unicode_520_ci'
	}, {
		name: 'ucs2_unicode_520_ci'
	}, {
		name: 'ucs2_vietnamese_ci'
	}],
}, {
	name: 'ujis',
	children: [{
		name: 'ujis_bin'
	}, {
		name: 'ujis_japanese_ci'
	}],
}, {
	name: 'utf8',
	children: [{
		name: 'utf8_bin'
	}, {
		name: 'utf8_croatian_ci'
	}, {
		name: 'utf8_czech_ci'
	}, {
		name: 'utf8_danish_ci'
	}, {
		name: 'utf8_esperanto_ci'
	}, {
		name: 'utf8_estonian_ci'
	}, {
		name: 'utf8_general_ci'
	}, {
		name: 'utf8_general_mysql500_ci'
	}, {
		name: 'utf8_german2_ci'
	}, {
		name: 'utf8_hungarian_ci'
	}, {
		name: 'utf8_icelandic_ci'
	}, {
		name: 'utf8_latvian_ci'
	}, {
		name: 'utf8_lithuanian_ci'
	}, {
		name: 'utf8_persian_ci'
	}, {
		name: 'utf8_polish_ci'
	}, {
		name: 'utf8_roman_ci'
	}, {
		name: 'utf8_romanian_ci'
	}, {
		name: 'utf8_sinhala_ci'
	}, {
		name: 'utf8_slovak_ci'
	}, {
		name: 'utf8_slovenian_ci'
	}, {
		name: 'utf8_spanish_ci'
	}, {
		name: 'utf8_spanish2_ci'
	}, {
		name: 'utf8_swedish_ci'
	}, {
		name: 'utf8_turkish_ci'
	}, {
		name: 'utf8_unicode_520_ci'
	}, {
		name: 'utf8_unicode_ci'
	}, {
		name: 'utf8_vietnamese_ci'
	}],
}, {
	name: 'utf8mb4',
	children: [{
		name: 'utf8mb4_bin'
	}, {
		name: 'utf8mb4_general_ci'
	}],
}, {
	name: 'utf16',
	children: [{
		name: 'utf16_bin'
	}],
}, {
	name: 'utf16le',
	children: [{
		name: 'utf16le_bin'
	}],
}, {
	name: 'utf32',
	children: [{
		name: 'utf32_bin'
	}],
}


]


/**
 * 
 * @param {转换配置} coverConfig 
 * @param {链接id} connId 
 * @param {数据库} catalog 
 * @param {表名字} tableName 
 * @param {获取回来的数据} data 
 */
 export const metadataCovert = (opt, covert, res,node) => {
    if (!res) {
        return [];
    }
    if (!res.success) {
        opt.message.error(res.message);
        return [];
    }
    const rows = res.rows;
    const result = [];
    for (const row of rows) {
        result.push(rowCovert(covert, row, node))
    }
    return result;
}

export const rowCovert = (covert, row, node) => {
			
    const d = metaDefaultConfg(node)
    covert(d, row, node);
    d.properties = Object.assign(d.properties, row)
    return d;
}

export const metaDefaultConfg = (node)=>{
				const {
					connId,
					catalog,
					tableName
				} = node.data.properties
    const d = {};
    d.leaf = false;
    d.properties = {};
    d.properties.pluginId = 'mysql'
    d.properties.connId = connId;
    d.properties.catalog = catalog;
    d.properties.tableName = tableName;
    return d;
}
